home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3576
/
3576.xpi
/
chrome
/
googleshortcuts.jar
/
content
/
googlebuttonsSettings.js
< prev
next >
Wrap
Text File
|
2009-11-10
|
5KB
|
119 lines
if(!de) var de={};
if(!de.soerenrinne) de.soerenrinne={};
if(!de.soerenrinne.GoogleButtons) de.soerenrinne.GoogleButtons={};
if(!de.soerenrinne.GoogleButtons.Settings) de.soerenrinne.GoogleButtons.Settings={};
de.soerenrinne.GoogleButtons.Settings = function (){
var pub = {};
googlebuttonsPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("de.soerenrinne.googlebuttons.");
var servicesList = googlebuttonsPrefs.getCharPref('wholeshebang');
var soerenrinneServicesArray = new Array();
soerenrinneServicesArray = servicesList.split(',');
soerenrinneServicesArray.sort(function(x,y){
var a = String(x).toUpperCase();
var b = String(y).toUpperCase();
if (a > b)
return 1
if (a < b)
return -1
return 0;
});
var soerenrinneNumberOfServices = soerenrinneServicesArray.length;
pub.loadOptions = function() {
try {
numberInColumn = soerenrinneNumberOfServices / 4;
// Add items
var vbox1 = document.getElementById("vbox1");
var vbox2 = document.getElementById("vbox2");
var vbox3 = document.getElementById("vbox3");
var vbox4 = document.getElementById("vbox4");
for (var j=0; j<soerenrinneNumberOfServices; j++) {
var id = soerenrinneServicesArray[j];
var idStripped = id.replace(/\ /g, "").toLowerCase();
var child = create_Checkbox(idStripped, " "+id);
if (document.getElementById(idStripped) == null) {
if (j < numberInColumn)
vbox1.appendChild(child);
else if (j < 2*numberInColumn)
vbox2.appendChild(child);
else if (j < 3*numberInColumn)
vbox3.appendChild(child);
else
vbox4.appendChild(child);
}
document.getElementById(idStripped).checked = googlebuttonsPrefs.getBoolPref(id);
}
document.getElementById("settings").checked = googlebuttonsPrefs.getBoolPref("settings");
document.getElementById("focustab").checked = googlebuttonsPrefs.getBoolPref("focustab");
document.getElementById("openintab").checked = googlebuttonsPrefs.getBoolPref("openintab");
if(googlebuttonsPrefs.getBoolPref('orient_horizontally') == true) {
document.getElementById('settingsOrientation').selectedItem = document.getElementById('orient_horizontally');
} else {
document.getElementById('settingsOrientation').selectedItem = document.getElementById('orient_vertically');
}
if(googlebuttonsPrefs.getBoolPref('dropdown') == false) {
document.getElementById('settingsDisplay').selectedItem = document.getElementById('toolbar');
} else {
document.getElementById('settingsDisplay').selectedItem = document.getElementById('dropdown');
}
} catch (e) {
alert("Error on loading settings:\n" + e.name + ", " + e.message);
}
}
pub.saveOptions = function() {
try {
for (var i=0;i<soerenrinneNumberOfServices;i++)
{
var id = soerenrinneServicesArray[i];
var idStripped = id.replace(/\ /g, "").toLowerCase();
if (document.getElementById(idStripped).checked)
googlebuttonsPrefs.setBoolPref(id, true);
else
googlebuttonsPrefs.setBoolPref(id, false);
}
(document.getElementById("settings").checked) ? googlebuttonsPrefs.setBoolPref("settings", true) : googlebuttonsPrefs.setBoolPref("settings", false);
(document.getElementById("focustab").checked) ? googlebuttonsPrefs.setBoolPref("focustab", true) : googlebuttonsPrefs.setBoolPref("focustab", false);
(document.getElementById("openintab").checked) ? googlebuttonsPrefs.setBoolPref("openintab", true) : googlebuttonsPrefs.setBoolPref("openintab", false);
(document.getElementById('orient_horizontally').selected == true) ? googlebuttonsPrefs.setBoolPref('orient_horizontally', true) : googlebuttonsPrefs.setBoolPref('orient_horizontally', false);
(document.getElementById('toolbar').selected == true) ? googlebuttonsPrefs.setBoolPref('dropdown', false) : googlebuttonsPrefs.setBoolPref('dropdown', true);
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
prefService.savePrefFile(null);
} catch (e) {
alert("Error on saving settings:\n" + e.name + ", " + e.message);
}
window.close();
}
create_Checkbox = function(aCheckboxID, aCheckboxLabel) {
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var item = document.createElementNS(XUL_NS, "checkbox"); // create a new XUL checkbox
item.setAttribute("id", aCheckboxID);
item.setAttribute("label", aCheckboxLabel);
item.setAttribute("src", "chrome://googlebuttons/skin/" + aCheckboxID + ".gif");
return item;
}
return pub;
}();